{extend name="admin@public/layout/popup"}

{block name="body"}
<div class="search-form-page-tab-content" id="search-form" style="display:none;">
    <div class="layui-form layui-card-header" style="height:auto;padding:0;">
        <form class="layui-form-item layui-form-pane" style="margin-bottom:0px;">
            <div class="layui-inline" style="padding-left: 10px;">
                <label class="layui-form-label" title="上级名称">上级名称</label>
                <div class="layui-input-inline">
                    <input type="text" id="pid" name="search_param[pid][value]" id="pid" placeholder="请选择" class="layui-input selectPage"
                    search-field="name"
                    search-url="{:url('admin/area/select_page')}"
                    show-field="name"
                    show-multiple="true"
                    >
                    <input type="hidden" name="search_param[pid][condition]" value="IN">
                </div>
            </div>

		    <div class="layui-inline" style="padding-left: 10px;">
                <label class="layui-form-label" title="简称">简称</label>
                <div class="layui-input-inline">
                    <input type="text" id="short_name" name="search_param[short_name][value]" placeholder="请输入简称" class="layui-input">
                    <input type="hidden" name="search_param[short_name][condition]" value="LIKE">
                </div>
            </div>

		    <div class="layui-inline" style="padding-left: 10px;">
                <label class="layui-form-label" title="名称">名称</label>
                <div class="layui-input-inline">
                    <input type="text" id="name" name="search_param[name][value]" placeholder="请输入名称" class="layui-input">
                    <input type="hidden" name="search_param[name][condition]" value="LIKE">
                </div>
            </div>

		    <div class="layui-inline" style="padding-left: 10px;">
                <label class="layui-form-label" title="全称">全称</label>
                <div class="layui-input-inline">
                    <input type="text" id="merge_name" name="search_param[merge_name][value]" placeholder="请输入全称" class="layui-input">
                    <input type="hidden" name="search_param[merge_name][condition]" value="LIKE">
                </div>
            </div>

		    <div class="layui-inline" style="padding-left: 10px;">
                <label class="layui-form-label" title="层级">层级</label>
                <div class="layui-input-inline">
                    <select id="level" name="search_param[level][value]" placeholder="请输入层级">
        				<option value=""></option>
						<option value="1">省</option>
						<option value="2">市</option>
						<option value="3">区县</option>
                    </select>
                    <input type="hidden" name="search_param[level][condition]" value="=">
                </div>
            </div>

		    <div class="layui-inline" style="padding-left: 10px;">
                <label class="layui-form-label" title="拼音">拼音</label>
                <div class="layui-input-inline">
                    <input type="text" id="pinyin" name="search_param[pinyin][value]" placeholder="请输入拼音" class="layui-input">
                    <input type="hidden" name="search_param[pinyin][condition]" value="LIKE">
                </div>
            </div>

		    <div class="layui-inline" style="padding-left: 10px;">
                <label class="layui-form-label" title="长途区号">长途区号</label>
                <div class="layui-input-inline">
                    <input type="text" id="code" name="search_param[code][value]" placeholder="请输入长途区号" class="layui-input">
                    <input type="hidden" name="search_param[code][condition]" value="LIKE">
                </div>
            </div>

		    <div class="layui-inline" style="padding-left: 10px;">
                <label class="layui-form-label" title="邮编">邮编</label>
                <div class="layui-input-inline">
                    <input type="text" id="zip" name="search_param[zip][value]" placeholder="请输入邮编" class="layui-input">
                    <input type="hidden" name="search_param[zip][condition]" value="LIKE">
                </div>
            </div>

		    <div class="layui-inline" style="padding-left: 10px;">
                <label class="layui-form-label" title="首字母">首字母</label>
                <div class="layui-input-inline">
                    <input type="text" id="first" name="search_param[first][value]" placeholder="请输入首字母" class="layui-input">
                    <input type="hidden" name="search_param[first][condition]" value="LIKE">
                </div>
            </div>

		    <div class="layui-inline" style="padding-left: 10px;">
                <label class="layui-form-label" title="经度">经度</label>
                <div class="layui-input-inline">
                    <input type="text" id="lng" name="search_param[lng][value]" placeholder="请输入经度" class="layui-input">
                    <input type="hidden" name="search_param[lng][condition]" value="LIKE">
                </div>
            </div>

		    <div class="layui-inline" style="padding-left: 10px;">
                <label class="layui-form-label" title="纬度">纬度</label>
                <div class="layui-input-inline">
                    <input type="text" id="lat" name="search_param[lat][value]" placeholder="请输入纬度" class="layui-input">
                    <input type="hidden" name="search_param[lat][condition]" value="LIKE">
                </div>
            </div>

        <div class="layui-inline" style="padding-left: 10px;">
            <button class="layui-btn layui-btn-sm layui-btn-primary" lay-submit lay-filter="laytp"><i class="layui-icon"></i> 搜 索</button>
        </div>
        </form>
    </div>
</div>
<table class="laytp-table layui-hide-sm" lay-filter="default"></table>
{/block}

{block name="script"}
<script>
layui.use(['layTp'],function() {
    const
        func_controller = {}
        ,layTp = layui.layTp
        ,$ = layui.jquery
    ;

    //批量操作渲染
    layui.dropdown.render({
        elem: '.action-more',
        options: [
            {
                action: "renew"
                ,title: "还原"
                ,icon: "layui-icon-list"
                ,uri: layTp.facade.url(module + "/" + controller + "/renew")
                ,switch_type: "confirm_action"
            }
            ,{
                action: 'true_del',
                title: '彻底删除'
                ,icon: "layui-icon-delete"
                ,uri: layTp.facade.url(module + "/" + controller + "/true_del")
                ,switch_type: "confirm_action"
            }
        ]
    });

    //表格渲染
    func_controller.table_render = function (where) {
        layui.table.render({
            elem: '.layui-hide-sm'
            , id: table_id
            , url: window.location.href
            , toolbar: '#default_toolbar'
            , where: where
            , even: true
            , method: 'GET'
            , cellMinWidth: 80
            , page: true
            , cols: [[
                {type:'checkbox'}
				,{field:'id',title:'ID',align:'center',width:80}
				,{field:'pid',title:'上级名称',align:'center',templet:'<div>{{# if(d.area){ }}{{d.area.name}}{{# }else{ }}-{{# } }}</div>'}
				,{field:'short_name',title:'简称',align:'center'}
				,{field:'name',title:'名称',align:'center'}
				,{field:'merge_name',title:'全称',align:'center'}
				,{field:'level',title:'层级',align:'center',templet:function(d){
					return layTp.facade.formatter.status('level',d.level,{"1":"省","2":"市","3":"区县"});
				}}
				,{field:'pinyin',title:'拼音',align:'center'}
				,{field:'code',title:'长途区号',align:'center'}
				,{field:'zip',title:'邮编',align:'center'}
				,{field:'first',title:'首字母',align:'center'}
				,{field:'lng',title:'经度',align:'center'}
				,{field:'lat',title:'纬度',align:'center'}
				,{field:'operation',title:'操作',align:'center',toolbar:'#operation',width:100}
            ]]
        });

        //监听默认工具条
        layui.table.on('tool(default)', function(obj){
            if(default_table_tool.indexOf(obj.event) != -1){
                layTp.facade.table_tool(obj);
            }else{
                //新增的其他操作按钮在这里来写
                //switch(obj.event){
                //    case '':
                //
                //        break;
                //}
            }
        });
    }

    func_controller.table_render();

    window.func_controller = func_controller;
});
</script>
{/block}

{block name="js_template"}
<script type="text/html" id="operation">
    <div class="layui-btn-group">
        <a class="layui-btn layui-btn-primary layui-btn-sm layui-icon layui-icon-list" lay-event="renew" title="还原" layer-tips="还原"> </a>
        <a class="layui-btn layui-btn-primary layui-btn-sm layui-icon layui-icon-delete" lay-event="true_del" title="彻底删除" layer-tips="彻底删除" colour="#f51c1c"> </a>
    </div>
</script>
<script type="text/html" id="default_toolbar">
    <div class="layui-table-tool-temp">
        <div class="layui-btn-group fl">
            <a href="javascript:void(0);" class="layui-btn layui-btn-primary layui-btn-sm layui-icon layui-icon-list action-more">&nbsp;批量操作</a>
            <a href="javascript:void(0);" class="layui-btn layui-btn-primary layui-btn-sm show-hidden-search-form layui-icon layui-icon-search">&nbsp;筛选</a>
        </div>
    </div>
</script>
{/block}